package com.soilflow.info.service.impl;

import com.soilflow.common.domain.LandProtocolEnroll;
import com.soilflow.common.domain.dto.LandProtocolEnrollDto;
import com.soilflow.common.domain.vo.LandProtocolEnrollVo;
import com.soilflow.common.utils.DateUtils;
import com.soilflow.common.utils.bean.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.soilflow.info.mapper.LandProtocolEnrollMapper;
import com.soilflow.info.service.LandProtocolEnrollService;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author dhp
 * @date 2023/4/28 - 10:48
 */
@Service
public class LandProtocolEnrollServiceImpl extends ServiceImpl<LandProtocolEnrollMapper, LandProtocolEnroll> implements LandProtocolEnrollService {


    /* *查询【转让协议报名】
     *
     * @param id 【转让协议报名】主键
     * @return 【转让协议报名】
     */
    @Override
    public LandProtocolEnrollVo selectLandProtocolEnrollById(Long id) {
        LandProtocolEnrollVo landProtocolEnrollVos = this.baseMapper.selectLandProtocolEnrollById(id);
        return landProtocolEnrollVos;
    }

    /**
     * 查询【转让协议报名】列表
     *
     * @param dto 【转让协议报名】
     * @return 【转让协议报名】集合
     */
    @Override
    public List<LandProtocolEnrollVo> selectLandProtocolEnrollList(LandProtocolEnrollDto dto) {
        List<LandProtocolEnrollVo> landProtocolEnrollVos = this.baseMapper.selectLandProtocolEnrollList(dto);
        return landProtocolEnrollVos;
    }

    /**
     * 新增【转让协议报名】
     *
     * @param dto 【转让协议报名】
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean insertLandProtocolEnroll(LandProtocolEnrollDto dto) {
        boolean save = false;
        LandProtocolEnroll landProtocolEnroll = new LandProtocolEnroll();
        BeanUtils.copyProperties(dto, landProtocolEnroll);
        landProtocolEnroll.setEnrollAt(DateUtils.getNowDate());
        save = this.save(landProtocolEnroll);
        return save;
    }

    /**
     * 修改【转让协议报名】
     *
     * @param dto 【转让协议报名】
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateLandProtocolEnroll(LandProtocolEnrollDto dto) {
        boolean save = false;
        LandProtocolEnroll landProtocolEnroll = new LandProtocolEnroll();
        BeanUtils.copyProperties(dto, landProtocolEnroll);
        //新增转让协议报名
        save = this.updateById(landProtocolEnroll);
        return save;
    }

    /**
     * 批量删除【转让协议报名】
     *
     * @param ids 需要删除的【转让协议报名】主键集合
     * @return 结果
     */
    @Override
    public Boolean deleteLandProtocolEnrollByIds(List<Long> ids) {
        return this.removeByIds(ids);
    }

}

